<template>
  <div>
    <el-button type="danger" @click="printTable">打印</el-button>
    <div id="form">

      <h2 style="text-align: center">合同信息</h2>
      <table border="1" style="border-collapse: collapse; width: 100%;">
        <thead>
        <tr>
          <th>合同编号</th>
          <th>合同名称</th>
          <th>合同类型</th>
          <th>合同金额</th>
          <th>合同签署时间</th>
          <th>签署人</th>
          <th>合同状态</th>
          <th>合同有效期</th>
          <th>文件名</th>
          <th>备注</th>
        </tr>
        </thead>
        <tbody>
        <tr v-for="contract in contracts" :key="contract.id">
          <td>{{ contract.contractNumber }}</td>
          <td>{{ contract.contractName }}</td>
          <td>{{ contract.contractType }}</td>
          <td>{{ contract.contractAmount }}</td>
          <td>{{ contract.signingDate }}</td>
          <td>{{ contract.signer }}</td>
          <td>{{ contract.status }}</td>
          <td>{{ contract.validityPeriod }}</td>
          <td>{{ contract.fileName }}</td>
          <td>{{ contract.notes }}</td>
        </tr>
        </tbody>
      </table>
    </div>
  </div>

</template>

<script>
import { getLodop } from "@/utils/LodopFuncs"
export default {
  name: 'HomeView',
  data() {
    return {
      contracts: [
        {
          id: 1, contractNumber: 'H001', contractName: '服务合同A', contractType: '服务', contractAmount: '5000',
          signingDate: '2025-01-15', signer: '张三', status: '有效', validityPeriod: '2025-12-31', fileName: 'contract_A.pdf', notes: '无'
        },
        {
          id: 2, contractNumber: 'H002', contractName: '产品采购B', contractType: '采购', contractAmount: '15000',
          signingDate: '2025-01-20', signer: '李四', status: '有效', validityPeriod: '2026-01-20', fileName: 'contract_B.pdf', notes: '急需'
        },
        {
          id: 3, contractNumber: 'H003', contractName: '合作协议C', contractType: '合作', contractAmount: '8000',
          signingDate: '2025-02-05', signer: '王五', status: '有效', validityPeriod: '2025-12-31', fileName: 'contract_C.pdf', notes: '审核中'
        },
        {
          id: 4, contractNumber: 'H004', contractName: '租赁合同D', contractType: '租赁', contractAmount: '20000',
          signingDate: '2025-02-10', signer: '赵六', status: '有效', validityPeriod: '2026-02-10', fileName: 'contract_D.pdf', notes: '续租'
        },
        {
          id: 5, contractNumber: 'H005', contractName: '咨询合同E', contractType: '咨询', contractAmount: '3000',
          signingDate: '2025-02-15', signer: '钱七', status: '有效', validityPeriod: '2025-12-15', fileName: 'contract_E.pdf', notes: '无'
        },
        {
          id: 6, contractNumber: 'H006', contractName: '服务合同F', contractType: '服务', contractAmount: '6000',
          signingDate: '2025-02-20', signer: '孙八', status: '有效', validityPeriod: '2026-02-20', fileName: 'contract_F.pdf', notes: '定期检查'
        },
        {
          id: 7, contractNumber: 'H007', contractName: '采购合同G', contractType: '采购', contractAmount: '25000',
          signingDate: '2025-03-01', signer: '周九', status: '有效', validityPeriod: '2026-03-01', fileName: 'contract_G.pdf', notes: '紧急订单'
        },
        {
          id: 8, contractNumber: 'H008', contractName: '协议合同H', contractType: '协议', contractAmount: '7000',
          signingDate: '2025-03-05', signer: '吴十', status: '有效', validityPeriod: '2025-09-05', fileName: 'contract_H.pdf', notes: '待续签'
        },
        {
          id: 9, contractNumber: 'H009', contractName: '建设合同I', contractType: '建设', contractAmount: '100000',
          signingDate: '2025-03-10', signer: '郑十一', status: '有效', validityPeriod: '2027-03-10', fileName: 'contract_I.pdf', notes: '需监理'
        },
        {
          id: 10, contractNumber: 'H010', contractName: '开发合同J', contractType: '开发', contractAmount: '40000',
          signingDate: '2025-03-15', signer: '冯十二', status: '有效', validityPeriod: '2026-03-15', fileName: 'contract_J.pdf', notes: '阶段性支付'
        },
        {
          id: 11, contractNumber: 'H011', contractName: '许可协议K', contractType: '许可', contractAmount: '9500',
          signingDate: '2025-03-16', signer: '陈十三', status: '有效', validityPeriod: '2025-11-16', fileName: 'contract_K.pdf', notes: '无'
        },
        {
          id: 12, contractNumber: 'H012', contractName: '保密合同L', contractType: '保密', contractAmount: '3000',
          signingDate: '2025-03-17', signer: '蔡十四', status: '有效', validityPeriod: '2025-12-17', fileName: 'contract_L.pdf', notes: '无'
        },
        {
          id: 13, contractNumber: 'H013', contractName: '转让协议M', contractType: '转让', contractAmount: '12000',
          signingDate: '2025-03-18', signer: '杜十五', status: '有效', validityPeriod: '2026-03-18', fileName: 'contract_M.pdf', notes: '待确认'
        },
        {
          id: 14, contractNumber: 'H014', contractName: '委托合同N', contractType: '委托', contractAmount: '5000',
          signingDate: '2025-03-19', signer: '李十六', status: '有效', validityPeriod: '2025-11-19', fileName: 'contract_N.pdf', notes: '无'
        },
        {
          id: 15, contractNumber: 'H015', contractName: '资产购买合同O', contractType: '购买', contractAmount: '200000',
          signingDate: '2025-03-20', signer: '沈十七', status: '有效', validityPeriod: '2028-03-20', fileName: 'contract_O.pdf', notes: '融资中'
        },
        {
          id: 16, contractNumber: 'H016', contractName: '融资协议P', contractType: '融资', contractAmount: '50000',
          signingDate: '2025-03-21', signer: '冯十八', status: '有效', validityPeriod: '2026-03-21', fileName: 'contract_P.pdf', notes: '审计中'
        },
        {
          id: 17, contractNumber: 'H017', contractName: '市场推广合同Q', contractType: '推广', contractAmount: '7000',
          signingDate: '2025-03-22', signer: '朱十九', status: '有效', validityPeriod: '2026-03-22', fileName: 'contract_Q.pdf', notes: '待沟通'
        },
        {
          id: 18, contractNumber: 'H018', contractName: '财务顾问合同R', contractType: '顾问', contractAmount: '5000',
          signingDate: '2025-03-23', signer: '巴二十', status: '有效', validityPeriod: '2025-09-23', fileName: 'contract_R.pdf', notes: '无'
        },
        {
          id: 19, contractNumber: 'H019', contractName: '法律顾问合同S', contractType: '顾问', contractAmount: '15000',
          signingDate: '2025-03-24', signer: '许二一', status: '有效', validityPeriod: '2026-03-24', fileName: 'contract_S.pdf', notes: '无'
        },
        {
          id: 20, contractNumber: 'H020', contractName: '跨国采购合同T', contractType: '采购', contractAmount: '18000',
          signingDate: '2025-03-25', signer: '何二二', status: '有效', validityPeriod: '2026-03-25', fileName: 'contract_T.pdf', notes: '无'
        },
        {
          id: 21, contractNumber: 'H001', contractName: '服务合同A', contractType: '服务', contractAmount: '5000',
          signingDate: '2025-01-15', signer: '张三', status: '有效', validityPeriod: '2025-12-31', fileName: 'contract_A.pdf', notes: '无'
        },
        {
          id: 22, contractNumber: 'H002', contractName: '产品采购B', contractType: '采购', contractAmount: '15000',
          signingDate: '2025-01-20', signer: '李四', status: '有效', validityPeriod: '2026-01-20', fileName: 'contract_B.pdf', notes: '急需'
        },
        {
          id: 23, contractNumber: 'H003', contractName: '合作协议C', contractType: '合作', contractAmount: '8000',
          signingDate: '2025-02-05', signer: '王五', status: '有效', validityPeriod: '2025-12-31', fileName: 'contract_C.pdf', notes: '审核中'
        },
        {
          id: 24, contractNumber: 'H004', contractName: '租赁合同D', contractType: '租赁', contractAmount: '20000',
          signingDate: '2025-02-10', signer: '赵六', status: '有效', validityPeriod: '2026-02-10', fileName: 'contract_D.pdf', notes: '续租'
        },
        {
          id: 25, contractNumber: 'H005', contractName: '咨询合同E', contractType: '咨询', contractAmount: '3000',
          signingDate: '2025-02-15', signer: '钱七', status: '有效', validityPeriod: '2025-12-15', fileName: 'contract_E.pdf', notes: '无'
        },
        {
          id: 26, contractNumber: 'H006', contractName: '服务合同F', contractType: '服务', contractAmount: '6000',
          signingDate: '2025-02-20', signer: '孙八', status: '有效', validityPeriod: '2026-02-20', fileName: 'contract_F.pdf', notes: '定期检查'
        },
        {
          id: 27, contractNumber: 'H007', contractName: '采购合同G', contractType: '采购', contractAmount: '25000',
          signingDate: '2025-03-01', signer: '周九', status: '有效', validityPeriod: '2026-03-01', fileName: 'contract_G.pdf', notes: '紧急订单'
        },
        {
          id: 28, contractNumber: 'H008', contractName: '协议合同H', contractType: '协议', contractAmount: '7000',
          signingDate: '2025-03-05', signer: '吴十', status: '有效', validityPeriod: '2025-09-05', fileName: 'contract_H.pdf', notes: '待续签'
        },
        {
          id: 29, contractNumber: 'H009', contractName: '建设合同I', contractType: '建设', contractAmount: '100000',
          signingDate: '2025-03-10', signer: '郑十一', status: '有效', validityPeriod: '2027-03-10', fileName: 'contract_I.pdf', notes: '需监理'
        },
        {
          id: 30, contractNumber: 'H010', contractName: '开发合同J', contractType: '开发', contractAmount: '40000',
          signingDate: '2025-03-15', signer: '冯十二', status: '有效', validityPeriod: '2026-03-15', fileName: 'contract_J.pdf', notes: '阶段性支付'
        },
        {
          id: 31, contractNumber: 'H011', contractName: '许可协议K', contractType: '许可', contractAmount: '9500',
          signingDate: '2025-03-16', signer: '陈十三', status: '有效', validityPeriod: '2025-11-16', fileName: 'contract_K.pdf', notes: '无'
        },
        {
          id: 32, contractNumber: 'H012', contractName: '保密合同L', contractType: '保密', contractAmount: '3000',
          signingDate: '2025-03-17', signer: '蔡十四', status: '有效', validityPeriod: '2025-12-17', fileName: 'contract_L.pdf', notes: '无'
        },
        {
          id: 33, contractNumber: 'H013', contractName: '转让协议M', contractType: '转让', contractAmount: '12000',
          signingDate: '2025-03-18', signer: '杜十五', status: '有效', validityPeriod: '2026-03-18', fileName: 'contract_M.pdf', notes: '待确认'
        },
        {
          id: 34, contractNumber: 'H014', contractName: '委托合同N', contractType: '委托', contractAmount: '5000',
          signingDate: '2025-03-19', signer: '李十六', status: '有效', validityPeriod: '2025-11-19', fileName: 'contract_N.pdf', notes: '无'
        },
        {
          id: 35, contractNumber: 'H015', contractName: '资产购买合同O', contractType: '购买', contractAmount: '200000',
          signingDate: '2025-03-20', signer: '沈十七', status: '有效', validityPeriod: '2028-03-20', fileName: 'contract_O.pdf', notes: '融资中'
        },
        {
          id: 36, contractNumber: 'H016', contractName: '融资协议P', contractType: '融资', contractAmount: '50000',
          signingDate: '2025-03-21', signer: '冯十八', status: '有效', validityPeriod: '2026-03-21', fileName: 'contract_P.pdf', notes: '审计中'
        },
        {
          id: 37, contractNumber: 'H017', contractName: '市场推广合同Q', contractType: '推广', contractAmount: '7000',
          signingDate: '2025-03-22', signer: '朱十九', status: '有效', validityPeriod: '2026-03-22', fileName: 'contract_Q.pdf', notes: '待沟通'
        },
        {
          id: 38, contractNumber: 'H018', contractName: '财务顾问合同R', contractType: '顾问', contractAmount: '5000',
          signingDate: '2025-03-23', signer: '巴二十', status: '有效', validityPeriod: '2025-09-23', fileName: 'contract_R.pdf', notes: '无'
        },
        {
          id: 39, contractNumber: 'H019', contractName: '法律顾问合同S', contractType: '顾问', contractAmount: '15000',
          signingDate: '2025-03-24', signer: '许二一', status: '有效', validityPeriod: '2026-03-24', fileName: 'contract_S.pdf', notes: '无'
        },
        {
          id: 40, contractNumber: 'H020', contractName: '跨国采购合同T', contractType: '采购', contractAmount: '18000',
          signingDate: '2025-03-25', signer: '何二二', status: '有效', validityPeriod: '2026-03-25', fileName: 'contract_T.pdf', notes: '无'
        }
      ]
    };
  },
  methods:{
    printTable(){
      let LODOP = getLodop();
      if(!LODOP){
        this.$message.error("未安装打印插件");
        return;
      }
      LODOP.SET_SHOW_MODE('LANDSCAPE_DEFROTATED', 1)
      LODOP.SET_PRINT_PAGESIZE(2, 0, 0, 'A4')
      LODOP.ADD_PRINT_HTM(15,0,'100%', '100%', document.getElementById('form').innerHTML)
      LODOP.SET_PRINT_MODE('PRINT_PAGE_PERCENT', 'Width:100%;Height:100%')
      LODOP.PREVIEW();
      this.$message.success('已发送至打印机');
    },
  }
}
</script>
